package com.hongning.railway.ui.adapter;

import android.databinding.ViewDataBinding;
import android.view.View;

import com.hongning.railway.R;
import com.hongning.railway.databinding.ItemRankBinding;
import com.hongning.railway.ui.main.mine.score.itemviewmodel.RankItemViewModel;

import me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter;

public class RankAdapter extends BindingRecyclerViewAdapter<RankItemViewModel> {

    @Override
    public void onBindBinding(ViewDataBinding binding, int variableId, int layoutRes, int position, RankItemViewModel item) {
        super.onBindBinding(binding, variableId, layoutRes, position, item);
        ItemRankBinding rankBinding = (ItemRankBinding) binding;
        if (position ==0){
            rankBinding.ivTop.setImageResource(R.mipmap.icon_top1);
            rankBinding.tvRank.setVisibility(View.GONE);
        }else if (position==1){
            rankBinding.ivTop.setImageResource(R.mipmap.icon_top2);
            rankBinding.tvRank.setVisibility(View.GONE);
        }else if (position ==2){
            rankBinding.ivTop.setImageResource(R.mipmap.icon_top3);
            rankBinding.tvRank.setVisibility(View.GONE);
        }else {
            rankBinding.ivTop.setVisibility(View.GONE);
            rankBinding.tvRank.setVisibility(View.VISIBLE);
            rankBinding.tvRank.setText(String.valueOf(position+1));
        }
    }
}
